{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post" onsubmit="return false;">
          
             
             <div class="layui-form-item">
                   <label class="layui-form-label">头像图片</label>
                 <div class="layui-input-inline">
                        <div class="profile-avatar-container profile-user-img">
                  <img id="image" class="profile-user-img" src="{$img.url|default='/static/libs/images/no_image.jpg'}" alt="">
            <span class="layui-upload-list">
                   <div class="profile-avatar-text">{:__('Click Edit')}</div>
               <button type="button" id="ajax-admin-avatar"><i class="fa fa-upload"></i>{:__('Edit')}</button>
            </span>
            <span class="layui-upload-list" style="padding-left: 20px;"></span>
                       </div>
                   </div>
            <input type="hidden" name="filesize" id="filesize" value="">
            <input type="hidden" name="mine" id="mine" value="">
            <input type="hidden" name="image" value="">
           </div>
     <div class="layui-form-item">
      <label class="layui-form-label">到期时间</label>
       <div class="layui-input-block">
        <input type="text" class="layui-input ID-laydate-shortcut-date" id="expire_time" style="width: 95%" name="expire_time" value="<?php echo turn_time($data['userToken']['expire_time']??time());?>">
      </div>
    </div>
               <!--  div class="layui-form-item">
                <label class="layui-form-label">到期时间</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="expire_time" title="不限时间" lay-filter="exptime">
                </div>
                <div class="layui-input-inline">
                    <input type="text" id="exptime" name="expire_time" value="<?php echo turn_time($data['userToken']['expire_time']??turn_time(date('Y-m-d')));?>" id="exptime" autocomplete="off" class="layui-input">
                </div>
            </div>
            <<div class="layui-form-item">
                <label class="layui-form-label">到期时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="expire_time" name="expire_time" value="<?php echo turn_time($data['userToken']['expire_time']??turn_time(date('Y-m-d')));?>" id="expire_time" autocomplete="off" class="layui-input" lay-filter="expire_time">
                </div>
            </div> -->
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('Member')}</label>
            <div class="layui-input-block">
                <input type="text" name="username" id="username" value="{$data.username|default=''}" style="width: 95%" lay-verify="required" placeholder="{:__('enter one user name')}" autocomplete="off" class="layui-input">
            </div>
        </div>  
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('password')}</label>
            <div class="layui-input-block">
                <input type="password" name="password" id="password" lay-verify="password" style="width: 95%" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('Mailbox')}</label>
           <div class="layui-input-block">
                <input type="text" placeholder="邮箱" id="email" name="email" value="{$data.email|default=''}" style="width: 95%" lay-verify="email" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('phone')}</label>
             <div class="layui-input-block">
                <input type="text" name="mobile" id="mobile" value="{$data.mobile|default=''}" style="width: 95%" lay-verify="required"
                       placeholder="请输入手机号"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" lay-filter="save" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger close">关闭</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}

<script>
layui.use(function(){
  var laydate = layui.laydate;
  var util = layui.util;
  /*
   * 快捷选项
   */
  // 日期
  laydate.render({
    elem: ".ID-laydate-shortcut-date",
    shortcuts: [
      {
        text: "昨天",
        value: function(){
          var now = new Date();
          now.setDate(now.getDate() - 1);
          return now;
        }
      },
      { 
        text: "今天", 
        value: function(){
          return Date.now();
        } 
      },
      {
        text: "明天",
        value: function(){
          var now = new Date();
          now.setDate(now.getDate() + 1);
          return now;
        }
      },
      {
        text: "上个月",
        value: function(){
          var now = new Date();
          var month = now.getMonth() - 1;
          now.setMonth(month);
          // 若上个月数不匹配，则表示天数溢出
          if (now.getMonth() !== month) {
            now.setDate(0); // 重置天数
          }
          return [now];
        }
      },
      {
        text: "下个月",
        value: function(){
          var now = new Date();
          var month = now.getMonth() + 1;
          now.setMonth(month);
          // 若下个月数不匹配，则表示天数溢出
          if (now.getMonth() !== month) {
            now.setDate(0); // 重置天数
          }
          return [now];
        }
      },
      {
        text: "某一天",
        value: "2016-10-14"
      }
    ]
  });
});
</script>
<script type="text/javascript">
layui.use(function () {
             var upload = layui.upload; // 上传
             var form = layui.form;
             var $ = layui.jquery; 
             form.render();
   //普通图片上传
      var uploadInst = upload.render({
    elem: '#ajax-admin-avatar',
    exts: 'jpg|png|jpeg|gif|svg',
    size: 2048,
    url: "{:url('upload/uploadImage',['model'=>'3'])}", //Change to your own upload interface
    done: function (result) {
        //上传完毕回调
        if (result.code === 1) {
            $('#image').attr('src', result.url);
            //this.item.prev('input').val(result.url);
            $('input[name="image"]').val(result.url);
            $('input[name="filesize"]').val(result.filesize);
            $('input[name="mine"]').val(result.mine);
            layer.msg(result.msg, {icon: 1});
        } else {
            layer.msg(result.msg, {icon: 2});
        }
    }
        });
});
   
    // form.on('checkbox(exptime)', function(data){
    //     if(data.elem.checked == true){
    //         $('#exptime').hide();
    //         $('#exptime').attr('value','2080-12-31');
    //     }else{
    //         $('#exptime').show();
    //     }
    // });
    // <?php $today = date('Y-m-d',time());?>
    // laydate.render({
    //     elem: '#exptime'
    //     ,min: '{$today}'
    //     ,max: '2080-12-31'
    // });

window.formClose = function(){
         var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
         parent.layer.close(index); //再执行关闭   
}

</script>
{/block}

